<?php
namespace app\index\validate;

use think\Validate;

/**
 * 管理员验证器
 * Class AdminUser
 * @package app\admin\validate
 */
class User extends Validate
{
    protected $rule = [
        'username'         => 'require|unique:user|alphaDash|length:5,18|regex:^[A-Za-z]\w{5,17}$',
        'password'         => 'require|confirm:confirm_password|regex:^[a-zA-Z]\w{5,17}$',
        'confirm_password' => 'confirm:password',
        'mobile'           => 'require|unique:user|regex:^1[34578]\d{9}$',
        'sex'              => 'require|number|in:0,1,2',
    ];

    protected $message = [
        'username.require'         => '请输入用户名',
        'username.unique'          => '用户名已存在',
        'username.alphaDash'       => '仅支持数字,字母,下划线',
        'username.length'          => '长度6-18位之间',
        'username.regex'           => '第一个必须是字母',
        'password.require'         => '请输入密码',
        'password.regex'           => '以字母开头，长度在6-18之间，只能包含字母、数字和下划线',
        'password.confirm'         => '两次输入密码不一致',
        'confirm_password.confirm' => '两次输入密码不一致',
        'mobile.require'           => '请输入手机号码',
        'mobile.regex'             => '请输入正确的手机号码',
        'mobile.unique'            => '手机号码已存在',
        'sex.require'              => '参数错误',
        'sex.number'               => '参数错误',
        'sex.in'                   => '参数错误',
    ];
}